<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="/wondershare/styles/main.css" rel="stylesheet" type="text/css" />
<link href="/wondershare/styles/general.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/wondershare/js/jquery.js"></script> 
<script type="text/javascript">
function goCheck( i ){
	document.location.href= "?action=index&web_type=<{$web_type}>&check_state="+i;	
}

function checkForm(){
	var hadSelect = false;
	$("input[id^='did_']").each(function(){
		if( $(this).attr('checked') ){
			hadSelect = true;
		}
	});	

	if( hadSelect ){
		return true;	
	}else{
		alert("选中项不能为空！");
		return false;	
	}
}

function subForm( s ){
	$("#check_state").val( s );
	if( checkForm() ) $("#myform").submit();
}

function del(){
	if( !checkForm() ) return;
	var ret = window.confirm("您确定要删除选中项？");	
	if( ret ){
		$("#myform").attr("action","?action=del&web_type=<{$web_type}>");
		$("#myform").submit();
	}
}

//note 推荐
function rec( did, pid, is_rec ){
	$.post('?action=rec&web_type=<{$web_type}>&r='+Math.random(),{'did':did,'pid':pid,'is_rec':is_rec},function(data){//alert(data)
		if( is_rec == 1 ){
			$("#rec_"+did).html('<span style="color:green;">推荐成功</span>');
			$("#img_"+did).attr('src','/wondershare/images/yes.gif');
		}else{
			$("#rec_"+did).html('<span style="color:green;">取消成功</span>');
			$("#img_"+did).attr('src','/wondershare/images/no.gif');
		}
		$("body").append( data );
	})
}

//note 搜索
function searchFun(){
	var s_pid = $("#s_pid").val();
	var s_pname = $("#s_pname").val();
	
	if( !s_pid && !s_pname ){
		alert('请输入产品ID或产品名！');
		return;	
	}
	document.location.href = document.location.href+'&s_pid='+s_pid+'&s_pname='+s_pname;
}

//note 回复
function reply( did ){
	parent.art.dialog(
		{
			id:"reply",
			title:"回复评论",
			iframe:"./wondershare/templates/product_review_reply.htm?did="+did,
			width:"600px",
			height:"170px"
		},
		function(){
			var _dialog = parent.art.dialog({id:'reply'});
			_dialog.data.iframe.reply( _dialog );
			return false;
		}
	);
}

//note 转发客服
function transpood( did ){
	
	var ret = window.confirm('您确认将此评论信息转发客服？');
	if( ! ret ) return;
	
	$("#transpood_"+did).html('<span style="color:#4FE635;">正在转发...</span>');	
		
	$.post('?action=transpood&web_type=<{$web_type}>&r='+Math.random(),{did:did},function(data){
		if( data == 1 ){
			$("#transpood_"+did).replaceWith('<span style="color:green;">转发成功</span>');	
		}else{
			$("#transpood_"+did).replaceWith('<span style="color:red;">转发失败</span>');
		}
	});
}

</script>
</head>

<body>

<div style="margin:8px; margin-bottom:0px;">
        <label><input type="radio" name="check" <{if $check_state==0}>checked="checked" <{/if}> onclick="goCheck(0)" value="0" />待审核</label> 
        <label><input type="radio" name="check" <{if $check_state==1}>checked="checked" <{/if}>  onclick="goCheck(1)" value="1" />审核通过</label> 
        <label><input type="radio" name="check" <{if $check_state==2}>checked="checked" <{/if}>  onclick="goCheck(2)" value="2" />审核未通过</label>
        
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;产品ID：<input type="text" size="8" id="s_pid" value="<{$s_pid}>" /> &nbsp;&nbsp;&nbsp;产品名：<input type="text" size="30" id="s_pname" value="<{$s_pname}>" /> &nbsp;&nbsp;&nbsp;<input type="button" value="搜索" onclick="searchFun()" />
    </div>
<form id="myform" name="myform" method="post" action="?action=check_state&web_type=<{$web_type}>">    
    <table cellpadding="2" cellspacing="1" width="100%" class="list-div">
    <tr><th width="50">产品ID</th>
    <th>产品名</th>
    <th width="30">星数</th><th>评论标题</th><th width="250">评论内容</th>
    <th>姓名</th><th>邮箱</th>
    <th width="60">评论日期</th>
    <!--<th width="40">支持</th><th width="40">反对</th>-->
    <{if $check_state != 0}><th width="60">审核人</th><th width="60">审核日期</th><{/if}>
    <{if $check_state == 1}><th>是否推荐</th><{/if}><th width="60">操作</th>
    </tr>
    
    <{foreach from=$data item=v}>
    <tr><td><label><input id="did_<{$v.did}>" type="checkbox" name="did[]" value="<{$v.did}>" /><{$v.pid}></label></td>
    <td style="padding-left:6px;"><{$v.product_name}>
    <input type="hidden" name="pid[<{$v.did}>]" value="<{$v.pid}>" />
    <input type="hidden" name="pname[<{$v.did}>]" value="<{$v.product_name}>" />
    <input type="hidden" name="star[<{$v.did}>]" value="<{$v.star}>" />
    </td>
    <td align="center"><{$v.star}></td><td style="padding-left:6px;"><{$v.title}></td><td style="padding-left:6px;"><{$v.review}></td>
    <td align="center"><{$v.username}></td><td align="center"><{$v.email}></td>
    <td align="center"><{$v.date}></td>
    <!--<td align="center"><{$v.support}></td><td align="center"><{$v.oppose}></td>-->
    <{if $check_state != 0}><td align="center"><{$v.check_user}></td><td align="center"><{$v.check_date}></td><{/if}>
    <{if $check_state == 1}><td align="center"><img id="img_<{$v.did}>" src="/wondershare/images/<{if $v.is_rec == 0}>no<{else}>yes<{/if}>.gif" /></td><{/if}>
     
     <td align="center" id="rec_<{$v.did}>">
     <{if $check_state == 1}>
     	<{if $v.is_rec == 0}>
     	<a href="javascript:rec(<{$v.did}>,<{$v.pid}>,1);">推荐</a><{else}><a href="javascript:rec(<{$v.did}>,<{$v.pid}>,0);" style="color:red;">取消推荐</a><{/if}>&nbsp;&nbsp;<{if $v.reply != ''}><a href="javascript:reply(<{$v.did}>);" style="color:red;">已回复</a><{else}><a href="javascript:reply(<{$v.did}>);">回复</a>
        <{/if}>
     <{/if}>
     <{if $v.is_transpood==1}><span style="color:red">已转发客服</span><{else}><a id="transpood_<{$v.did}>" href="javascript:transpood(<{$v.did}>);">转发客服</a><{/if}>
     </td>
   </tr>
    <{/foreach}>
    
    <tr><td><input type="checkbox" onclick="var v=document.getElementsByName('did[]');if(this.checked){for(i=0;i<v.length;i++)v[i].checked=true;}else{for(i=0;i<v.length;i++)v[i].checked=false;}" /> 全选</td>
    <td colspan="<{if $check_state != 0}><{if $check_state == 1}>12<{else}>10<{/if}><{else}>8<{/if}>">
    <{if $check_state != 1}><input type="button" value="选中项通过" onclick="subForm(1)" />&nbsp;&nbsp;<{/if}>
    <{if $check_state != 2}><input type="button" value="选中项不通过"  onclick="subForm(2)" />&nbsp;&nbsp;<{/if}>
    <input type="button" value="选中项删除" onclick="del()" />
    <input type="hidden" name="now_state" id="now_state" value="<{$check_state}>" />
    <input type="hidden" name="check_state" id="check_state" value="<{$check_state}>" />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <{$pages}>
    </td>
    
    </tr>
    </table>
   </form>
</body>
</html>
